const {
	User,
	validateLogin
} = require('../../../model/User');
// hash密码
const bcrypt = require('bcryptjs');
// 工具
const _ = require('lodash');

module.exports = async (req, res) => {
	const account = req.fields.account;
	if (account) {
		const user = await User.findOne({
			account
		});
		user.role == 15 && await User.findOneAndDelete({
			account
		});
	}
	req.session.destroy(err => {
		if (err) return res.sendResult(null, 400, '退出失败');
		res.clearCookie('connect-sid');
		res.sendResult(null, 200, '退出成功');
	});
};